package se.sll.itintegration.catalogue.offer.ejb;

import java.sql.Timestamp;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import lombok.extern.slf4j.Slf4j;
import se.sll.itintegration.catalogue.offer.entity.ContractEntity;
import se.sll.service.catalogue.common.AbstractJpaFacade;

/**
 *
 * @author khaled
 */
@Slf4j
@Stateless
public class ContractEjb extends AbstractJpaFacade<ContractEntity> {

    @PersistenceContext(unitName = "offerPU")
    private EntityManager em;

    public ContractEjb() {
        super(ContractEntity.class);
    }

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    @Override
    protected void setEntityManager(EntityManager em) {
        this.em = em;
    }

    @Override
    public void create(ContractEntity entity) {
        Timestamp ts = getTimeStamp();
        entity.setCreationTime(ts);
        entity.setUpdateTime(ts);
        super.create(entity);
    }

}
